import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect: "/login"
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  // 主界面路由
  {
    path: '/home',
    name: 'home',
    component: () => import("@/views/Home/home"),
    children: [
      // 主页
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import("@/views/Home/main/dashboard"),
        meta: {
          name: "首页"
        }
      },
      // 表格页
      {
        path: '/table',
        name: 'table',
        component: () => import("@/views/Home/main/table"),
        meta: {
          name: "基础表格"
        }
      },
      // 第二个首页
      {
        path: '/index',
        name: 'index',
        component: () => import("@/views/Home/main/index"),
      },
      // 用户列表
      {
        path: '/userlist',
        name: 'userlist',
        component: () => import("@/views/Home/main/userlista"),
        meta: {
          name: "用户列表"
        }
      },
      // 商品管理
      {
        path: '/goods',
        name: 'goods',
        component: () => import("@/views/Home/main/good"),
        meta: {
          name: "商品管理"
        }
      },
      // 品类管理
      {
        path: '/category',
        name: 'category',
        component: () => import("@/views/Home/main/category"),
        meta: {
          name: "品类管理"
        }
      },
      // 子品类管理
      {
        path: '/categoryzi/:id',
        name: 'categoryzi',
        component: () => import("@/views/Home/main/categoryzi"),
        meta: {
          name: "子品类管理"
        }
      },
      // 查看详情
      {
        path: '/details/:id',
        name: 'details',
        component: () => import("@/views/Home/main/details"),
        meta: {
          name: "商品详情"
        }
      },
      //  编辑商品
      {
        path: '/edit/:id',
        name: 'edit',
        component: () => import("@/views/Home/main/edit"),
        meta: {
          name: "商品修改"
        }
      },
      //  添加商品
      {
        path: '/addshop',
        name: 'addshop',
        component: () => import("@/views/Home/main/addshop"),
        meta: {
          name: "商品添加"
        }
      },
      //  订单管理
      {
        path: '/order',
        name: 'order',
        component: () => import("@/views/Home/main/order"),
        meta: {
          name: "订单管理"
        }
      },
      //  订单详情
      {
        path: '/order/:id',
        name: 'orderxq',
        component: () => import("@/views/Home/main/orderxq"),
        meta: {
          name: "订单详情"
        }
      },
    ]

  },
  // 登陆路由
  {
    path: '/login',
    name: 'login',
    component: () => import("@/views/Login/login")
  },
  {
    path: '/color',
    name: 'color',
    component: () => import("@/views/color")
  },
  {
    path: '/echart',
    name: 'echart',
    component: () => import("@/views/echart")
  },

]

const router = new VueRouter({
  mode: "history",
  routes
})

export default router
